import java.awt.image.BufferedImage;
import java.util.Timer;
import java.util.TimerTask;

public class Boom {

    //属性
    private Flyer boom_flyer;
    private int index = 0;//数组下标
    private int x,y,width,hight;
    private int boomtime;

    //构造器

    public Boom(Flyer boom_flyer) {
        this.boom_flyer = boom_flyer;
        x = boom_flyer.getX();
        y = boom_flyer.getY();
        width = boom_flyer.getWidth();
        hight = boom_flyer.getHight();
        boomtime = PlayPanel.getTime()+100;//下一帧爆炸图片刷新时间
    }

    //方法
    public BufferedImage getImage(){
        if (boom_flyer instanceof AirPlane){//如果是小敌机
            if (PlayPanel.getTime()>boomtime){
                boomtime = PlayPanel.getTime()+100;
                index++;
            }
            if (index<4){
                return Game.airboom[index];
            }else{
                return null;
            }

        }else if (boom_flyer instanceof BigPlane){//如果是英雄机
            if (PlayPanel.getTime()>boomtime){
                boomtime = PlayPanel.getTime()+100;
                index++;
            }
            if (index<4){
                return Game.bigboom[index];
            }else{
                return null;
            }
        }else if (boom_flyer instanceof HeroPlane){//如果是英雄机
            if (PlayPanel.getTime()>boomtime){
                boomtime = PlayPanel.getTime()+500;
                index++;
            }
            if (index<4){
                return Game.heroboom[index];
            }else{
                return null;
            }
        }else if (boom_flyer instanceof ExtraPlane){//如果是BOSS机
            if (PlayPanel.getTime()>boomtime){
                boomtime = PlayPanel.getTime()+200;
                index++;
            }
            if (index<5){
                return Game.extboom[index];
            }else{
                return null;
            }
        }else{
            return null;
        }

    }


    public Flyer getBoom_flyer() {
        return boom_flyer;
    }

    public void setBoom_flyer(Flyer boom_flyer) {
        this.boom_flyer = boom_flyer;
    }


    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHight() {
        return hight;
    }

    public void setHight(int hight) {
        this.hight = hight;
    }
}
